package com.community.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.community.pojo.Cart;
import com.community.mapper.CartMapper;
import com.community.pojo.Gather;
import com.community.service.ICartService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.community.utils.PageUtils;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author TangHaoSong Fly ChenJie HeYuHang
 * @since 2024-05-15
 */
@Service
public class CartServiceImpl extends ServiceImpl<CartMapper, Cart> implements ICartService {
    @Autowired
    private CartMapper cartMapper;
    @Override
    public void addCart(Cart cart) {
        cartMapper.insertCart(cart);
    }

    @Override
    public List<Cart> getCartsByConsumerId(Long consumerId) {
        return cartMapper.selectCartsByConsumerId(consumerId);
    }

    @Override
    public void updateCart(Cart cart) {
        cartMapper.updateCart(cart);
    }

    @Override
    public void deleteCart(Long id) {
        cartMapper.deleteCart(id);
    }

    @Override
    public List<Cart> selectCartProduct() {
        List<Cart> cart = cartMapper.selectCartProduct();
        List<Cart> list=new ArrayList<>(cart);
        return list;
    }
}
